import type { VxeUIExport } from 'vxe-table'

import { ElSwitch } from 'element-plus'

export function initCell(VxeUI: VxeUIExport) {
  // 表格配置项可以用 cellRender: { name: 'CellImage' },
  VxeUI.renderer.add('ElSwitch', {
    renderTableDefault(_renderOpts, params) {
      const { column, row } = params
      return h(ElSwitch, {
        modelValue: row[column.field],
        'onUpdate:modelValue': (value) => {
          row[column.field] = value
        },
      })
    },
  })
}
